<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="test1"></div>

<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>

<!-- jsx转为js -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>

<script type="text/babel">
    // 字符串的ref，存在效率问题
    class Person extends React.Component {
        showData = () => {
            /*let input = document.getElementById("input1")
            console.log(input.value)*/

            /*let input = document.getElementById("input1")
            console.log(input)*/

            console.log(this.refs.input1.value)
        }
        showData1 = () => {
            console.log(this.refs.input2.value)
        }

        render() {
            let {name, age, sex} = this.props
            return (
                   <div>
                       <input id="input1" ref="input1" type="text" placeholder="点击按钮提示"/>
                       <button onClick={this.showData}>点我提示数据</button>
                       <input ref="input2" onBlur={this.showData1} type="text" placeholder="失去焦点提示"/>
                   </div>
            )
        }
    }

    ReactDOM.render(<Person name="tom1" age={18} sex="女"/>, document.getElementById("test1"))
</script>
</body>
</html>